# 抓取 评论 https://m.weibo.cn/detail/5148396122803865
# 评论地址  https://m.weibo.cn/comments/hotflow?id=5148396122803865&mid=5148396122803865&max_id_type=0
import json
import re
import requests
import csv

url_ = 'https://m.weibo.cn/comments/hotflow?id=5148396122803865&mid=5148396122803865&max_id_type=0'
header = {
    'user-agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'
}
resq = requests.get(url=url_,headers=header)
datas = resq.json()['data']['data']
for data in datas:
    content = ''.join(re.findall(r'[\u4e00-\u9fa5]',data['text']))
    dict = {
        '评论内容':content,
        '评论时间':data['created_at'],
        '评论地点':data['source'].replace('来自',''),
        '评论人名称':data['user']['screen_name']

    }
    print(dict)
    # break